#!/bin/sh

source /etc/profile
if [ "$#" -ne "1" ]; then
    echo "[ERROR] usage: $0 <service-name>"
    exit 2
fi
process=$1
jarName="${process}"
if [ ! -f "$jarName" ]; then
  jarName="${process}-1.0.jar"
  if [ ! -f "$jarName" ]; then
    echo "[ERROR] [$jarName] not exists."
	exit -1
  fi
fi
p=$(ps -ef | grep "[^-]\b${jarName}\b" | grep 'java' | grep -v grep | awk '{print $2}')
for i in ${p}
do
  echo "Kill the [$1] process [ $jarName ]"
  kill -9 $i
done
echo "killed end"
exit 0
